<template>
	<view class="u-page__item">
		<view class="padding_tb_l">
			<u-tabs :list="list1" @click="tabClick"></u-tabs>
		</view>

		<view v-if="tabsIndex == 0">
			<!-- <view style="padding: 30rpx 0;">
				<fui-section isLine lineColor="#409EFF" title="单位动火证书"></fui-section>
			</view> -->
			<view v-if="certificateData == ''" style="margin: 0 auto; border-radius: 18rpx; border: 1px solid #CDD0D6;  width: 90%; height: 350rpx; display: flex; align-items: center; justify-content: center;">
				<view style="text-align: center; width: 80%;">
					<view @click="uploadCertificate">
						<view style="width: 120rpx; height: 120rpx; margin: 0 auto;">
							<image src="@/static/certificate.png" style="width: 100%; height: 80%;" mode=""></image>
							<!-- <up-empty text="点击上传动火证件" icon="@/static/certificate.png"></up-empty> -->
						</view>
						<text style="color: #C0C4CC; margin: 0 auto;">
							点击上传动火证件
						</text>
					</view>
				</view>
			</view>
			<view @click="onPreview(certificateData.hotWorkCertificate)" v-if="certificateData" style="margin: 0 auto; border-radius: 18rpx; border: 1px solid #CDD0D6;  width: 90%; height: 350rpx; display: flex; align-items: center; justify-content: center;">
				<image style="width: 100%; height: 350rpx; border-radius: 18rpx;" :src="base_ip + certificateData.hotWorkCertificate" mode="">
				</image>
			</view>

			<view v-if="certificateData">
				<view class="h-content">
					<view style="margin: 0 auto; width: 98%; height: 98%;">
						<fui-input readonly label="上传时间:" :bottomLeft="0" :value="certificateData.creationTime"></fui-input>
						<fui-input readonly label="有效日期:" :bottomLeft="0" borderTop :value="certificateData.startTime + ' 至 ' + certificateData.endTime"></fui-input>
						<fui-input readonly color="#409EFF" label="状态:" :bottomLeft="0" borderTop :value="certificateData.state"></fui-input>
					</view>
				</view>
				<view class="h-content">
					<view style="margin: 0 auto; width: 98%; height: 98%;">
						<fui-input readonly label="每天有效时间段:" :bottomLeft="0" :value="certificateData.timePeriodStarts + ' 至 ' + certificateData.end_of_time_period"></fui-input>
					</view>
				</view>
			</view>

			<view v-if="!certificateData">
				<view class="h-content">
					<view style="margin: 0 auto; width: 98%; height: 98%;">
						<!-- <fui-input readonly label="上传时间:" :bottomLeft="0" value="2025-3-20"></fui-input> -->
						<fui-input @click="showDataTimes =!showDataTimes" readonly label="有效日期:" :bottomLeft="0" borderTop :value="certificate.dataTimeTemp"></fui-input>
						<!-- <fui-input readonly color="#409EFF" label="状态:" :bottomLeft="0" borderTop value="未过期"></fui-input> -->
					</view>
				</view>
				<view class="h-content">
					<view style="margin: 0 auto; width: 98%; height: 98%;">
						<fui-input @click="showDayTimes =!showDayTimes" readonly label="每天有效时间段:" :bottomLeft="0" :value="certificate.dayTimeTemp"></fui-input>
					</view>
				</view>
			</view>

			<view class="h-content" v-if="certificateData">
				<view style="margin: 0 auto; width: 98%; height: 98%;">
					<fui-input readonly label="安全管理操作员:" borderTop :bottomLeft="0" :value="certificateData.securityOperatorsUserNickname"></fui-input>
					<fui-input readonly @click="onPreview(certificateData.securityOperatorsUserSignature)" v-if="certificateData.securityOperatorsUserSignature" label="签名:" borderTop :bottomLeft="0" value="已签名"></fui-input>

					<fui-input readonly v-if="!certificateData.securityOperatorsUserSignature" label="签名:" borderTop :bottomLeft="0" value="未签名" @click="showSignatureOfSafetyOperator =!showSignatureOfSafetyOperator"></fui-input>

					<fui-input readonly label="签名时间:" borderTop :bottomLeft="0" :value="certificateData.securityOperatorsUserTime"></fui-input>
				</view>

			</view>

			<view class="h-content" v-if="certificateData">
				<view style="margin: 0 auto; width: 98%; height: 98%;">
					<fui-input readonly label="单位负责人:" borderTop :bottomLeft="0" :value="certificateData.unitLeaderUserNickname"></fui-input>

					<fui-input readonly @click="onPreview(certificateData.unitLeaderUserSignature)" v-if="certificateData.unitLeaderUserSignature" label="签名:" borderTop :bottomLeft="0" value="已签名"></fui-input>

					<fui-input readonly @click="showSignatureOfResponsiblePerson =!showSignatureOfResponsiblePerson" v-if="!certificateData.unitLeaderUserSignature" label="签名:" borderTop :bottomLeft="0" value="未签名"></fui-input>

					<fui-input readonly label="签名时间:" borderTop :bottomLeft="0" :value="certificateData.unitLeaderUserTime"></fui-input>
				</view>
			</view>
		</view>
		<view v-else>
			<view class="h-content" v-if="filemans.length > 0">
				<view style="margin: 0 auto; width: 98%;">
					<up-list style="background-color: #fff; ">
						<fui-collapse-item v-for="(item,index) in filemans" :key="index">
							<view class="fui-item__box">
								<image style="width: 40rpx; height: 40rpx;" src="@/static/user_selct.png" class="fui-logo">
								</image>
								<text>动火操作员：{{item.nickName}}</text>
							</view>
							<template v-slot:content>
								<fui-input readonly color="#409EFF" @click="enableOff(item,0)" textAlign="right" v-if="item.enable == 1" value="已启用" label="状态:" borderTop></fui-input>

								<fui-input readonly color="#F56C6C" @click="enableOn(item,1)" textAlign="right" v-if="item.enable != 1" value="已禁用" label="状态:" borderTop></fui-input>

								<fui-input readonly color="#F56C6C" textAlign="right" v-if="item.faceAuthentication != 1" value="未认证" label="人脸认证状态:" borderTop></fui-input>

								<fui-input readonly color="#409EFF" textAlign="right" v-if="item.faceAuthentication == 1" value="已认证" label="人脸认证状态:" borderTop></fui-input>
								<view class="charts-user-list-son">
									<up-button type="error" shape="circle" @click="delFileMan(item)" text="删除此动火操作员"></up-button>
								</view>
							</template>
						</fui-collapse-item>
					</up-list>
				</view>
			</view>
		</view>
		<view v-if="certificateData">
			<fui-section isLine lineColor="#409EFF" title="动火操作员人脸过期时间"></fui-section>
			<view @click="showCron =!showCron" class="h-content" v-if="!certificateData.mtimedTaskDescription">
				<view style="margin: 0 auto; width: 98%; height: 98%;">
					<fui-input textAlign="right" readonly label="时间:" :bottomLeft="0" color="#F56C6C" value="未设置"></fui-input>
				</view>
			</view>

			<view class="h-content" v-if="certificateData.mtimedTaskDescription">
				<view style="margin: 0 auto; width: 98%; height: 98%;">

					<fui-input textAlign="right" readonly label="时间:" :bottomLeft="0" :value="certificateData.mtimedTaskDescription"></fui-input>
					<fui-input textAlign="right" borderTop color="#409EFF" v-if="certificateData.stimedState == 1" readonly label="状态:" :bottomLeft="0" value="已启用"></fui-input>
					<fui-input textAlign="right" borderTop color="#F56C6C" v-if="certificateData.stimedState != 1" readonly label="状态:" :bottomLeft="0" value="已禁用"></fui-input>
				</view>
			</view>
		</view>
		<view style="width: 90%; margin: 10rpx auto; padding-bottom: 20rpx;" v-if="certificateData">
			<u-button @click="showHList =!showHList" shape="circle">更多</u-button>
		</view>
		<view v-if="false">
			<view class="padding_tb_l">
				<fui-section isLine lineColor="#409EFF" title="单位动火设备"></fui-section>
			</view>
			<view v-if="devices.length >0">
				<view class="h-content">
					<up-list style="height: 800rpx;">
						<fui-collapse-item v-for="(item,index) in devices" :key="index" :title="'设备编号：' +  item.deviceNumber ">
							<view class="fui-item__box">
								<!-- <image src="@/static/user_selct.png" class="fui-logo"></image> -->
								<text>设备编号：{{item.deviceNumber}}</text>
							</view>
							<template v-slot:content>
								<fui-input readonly :value="item.createTime" label="创建时间:" borderTop></fui-input>
								<fui-input readonly :value="item.type" label="类型:" borderTop></fui-input>
								<fui-input readonly :value="item.faceSpan + '分钟'" label="人脸检测间隔时间:" borderTop></fui-input>
								<fui-input readonly color="#465CFF" v-if="item.enable == 1" value="启用" label="状态:" borderTop></fui-input>
								<fui-input readonly color="#FF2B2B" v-if="item.enable != 1" value="禁用" label="状态:" borderTop></fui-input>
								<fui-input readonly color="#09BE4F" v-if="item.states != 1" value="空闲中" label="作业状态:" borderTop></fui-input>
								<fui-input readonly color="#6831FF" v-if="item.states == 1" value="作业中" label="作业状态:" borderTop></fui-input>
								<view class="charts-user-list-son">
									<up-button shape="circle" @click="onShowFileMan(item)" text="添加动火操作员"></up-button>
								</view>
								<view class="charts-user-list-son">
									<up-button shape="circle" @click="toFileMan(item)" text="查看动火操作员"></up-button>
								</view>
								<view class="charts-user-list-son">
									<up-button shape="circle" @click="onDeviceOpsShow(item)" text="更多"></up-button>
								</view>
							</template>
						</fui-collapse-item>
					</up-list>
				</view>
				<view style="width: 90%; margin: 10rpx auto;" v-if="certificateData">
					<u--button @click="showAddDevice =!showAddDevice" shape="circle">添加动火设备</u--button>
				</view>
			</view>
			<view v-else-if="devices.length < 1" style="width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;">
				<view style="width: 80rpx; height: 80rpx;">
					<up-empty mode="data">
					</up-empty>
				</view>
			</view>
		</view>
	</view>

	<view>
		<up-modal @confirm="onAddDevice" :showCancelButton="true" @cancel="showAddDevice =!showAddDevice" @close="showAddDevice =!showAddDevice" :show="showAddDevice" title="添加设备">
			<view class="slot-content">
				<fui-input clearable type="number" maxlength="11" text-align="right" v-model="addDevice.number" label="设备编号" borderTop placeholder="请输入设备编号"></fui-input>
				<fui-input text-align="right" readonly @click="showdeviceTypes =!showdeviceTypes" v-model="addDevice.type" label="设备类型" borderTop placeholder="请选择设备类型"></fui-input>
				<fui-input text-align="right" readonly @click="showdeviceEnab =!showdeviceEnab" v-model="addDevice.enable.label" label="是否启用" borderTop placeholder="请选择"></fui-input>
				<fui-input text-align="right" readonly @click="showdeviceTime=!showdeviceTime" v-model="addDevice.faceSpan" label="人脸检测间隔时间" borderTop placeholder="请选择">
					<text>分钟</text>
				</fui-input>
			</view>
		</up-modal>

		<up-modal @confirm="onAddFileMan" :showCancelButton="true" @cancel="showAddFileMan =!showAddFileMan" @close="showAddFileMan =!showAddFileMan" :show="showAddFileMan" title="添加动火操作员">
			<view class="slot-content">
				<fui-input clearable maxlength="20" text-align="right" v-model="fileManAccount" label="账号" borderTop placeholder="请输入动火操作员账号"></fui-input>
			</view>
		</up-modal>
	</view>
	<view>
		<up-action-sheet @select="onDeviceOps" @close="showDeviceOps=!showDeviceOps" :round="18" :actions="deviceList" title="设置" :show="showDeviceOps"></up-action-sheet>
	</view>
	<view>
		<up-action-sheet @select="onHlist" @close="showHList=!showHList" :round="18" :actions="hList" title="更多" :show="showHList"></up-action-sheet>
	</view>
	<view>
		<view>
			<up-modal @confirm="onSelctDataTime" :show="showDataTimes" @cancel="showDataTimes =!showDataTimes" showCancelButton title="有效日期">
				<view class="slot-content">
					<fui-input label="开始日期" v-model="certificate.startDataTime" @click="showDataTimeStar =!showDataTimeStar" readonly placeholder="请选择开始日期"></fui-input>
					<fui-input label="结束日期" v-model="certificate.endDataTime" @click="showDataTimeEnd =!showDataTimeEnd" readonly borderTop placeholder="请选择结束日期"></fui-input>
				</view>
			</up-modal>

			<up-modal @confirm="onUpSelctDataTime" :show="showUpDataTimes" @cancel="showUpDataTimes =!showUpDataTimes" showCancelButton title="有效日期">
				<view class="slot-content">
					<fui-input label="开始日期" v-model="certificate.startDataTime" @click="showDataTimeStar =!showDataTimeStar" readonly placeholder="请选择开始日期"></fui-input>
					<fui-input label="结束日期" v-model="certificate.endDataTime" @click="showDataTimeEnd =!showDataTimeEnd" readonly borderTop placeholder="请选择结束日期"></fui-input>
				</view>
			</up-modal>


			<up-modal @confirm="onSelctDayTime" :show="showDayTimes" @cancel="showDayTimes =!showDayTimes" showCancelButton title="有效时段">
				<view class="slot-content">
					<fui-input label="每天开始时段" v-model="certificate.startDayTime" @click="showDayTimeStar =!showDayTimeStar" readonly placeholder="请选择开始时段"></fui-input>
					<fui-input label="每天结束时段" v-model="certificate.endDayTime" @click="showDayTimeEnd =!showDayTimeEnd" readonly borderTop placeholder="请选择结束时段"></fui-input>
				</view>
			</up-modal>

			<up-modal @confirm="onUpSelctDayTime" :show="showUpDayTimes" @cancel="showUpDayTimes =!showUpDayTimes" showCancelButton title="有效时段">
				<view class="slot-content">
					<fui-input label="每天开始时段" v-model="certificate.startDayTime" @click="showDayTimeStar =!showDayTimeStar" readonly placeholder="请选择开始时段"></fui-input>
					<fui-input label="每天结束时段" v-model="certificate.endDayTime" @click="showDayTimeEnd =!showDayTimeEnd" readonly borderTop placeholder="请选择结束时段"></fui-input>
				</view>
			</up-modal>

		</view>
		<view>
			<view>
				<up-datetime-picker :min-date="minTime" title="开始日期" @confirm="onDataTimeStar" @cancel="showDataTimeStar =!showDataTimeStar" @close="showDataTimeStar =!showDataTimeStar" closeOnClickOverlay ref="datetimePicker" mode="date" :show="showDataTimeStar" :formatter="formatter"></up-datetime-picker>
			</view>
			<view>
				<up-datetime-picker :min-date="minTime1" title="结束日期" @close="showDataTimeEnd =!showDataTimeEnd" @confirm="onDataTimeEnd" @cancel="showDataTimeEnd =!showDataTimeEnd" closeOnClickOverlay ref="datetimePicker" mode="date" :show="showDataTimeEnd" :formatter="formatter"></up-datetime-picker>
			</view>
		</view>
		<view>
			<view>
				<up-datetime-picker mode="time" title="开始时间" @confirm="onDayTimeStar" @cancel="showDayTimeStar =!showDayTimeStar" @close="showDayTimeStar =!showDayTimeStar" closeOnClickOverlay ref="datetimePicker" :show="showDayTimeStar"></up-datetime-picker>
			</view>

			<view>
				<up-datetime-picker title="结束时间" @close="showDayTimeEnd =!showDayTimeEnd" @confirm="onDayTimeEnd" @cancel="showDayTimeEnd =!showDayTimeEnd" closeOnClickOverlay ref="datetimePicker" mode="time" :show="showDayTimeEnd" :formatter="formatter"></up-datetime-picker>
			</view>
			<view>
				<up-picker :show="showUpStates" :columns="states"></up-picker>
			</view>
		</view>
		<view class="h-sign">
			<view>
				<up-picker title="选择时间" @confirm="onSelectDevTimes" @cancel="showdeviceTime =!showdeviceTime" :show="showdeviceTime" :columns="deviceTimes"></up-picker>

				<up-picker title="选择时间" @confirm="onSelectDevTimes1" @cancel="showdeviceTime1 =!showdeviceTime1" :show="showdeviceTime1" :columns="deviceTimes"></up-picker>
			</view>
			<view>
				<up-picker title="选择类型" @confirm="onSelectDevType" @cancel="showdeviceTypes =!showdeviceTypes" @close="showdeviceTypes =!showdeviceTypes" :show="showdeviceTypes" :columns="deviceTypes"></up-picker>
			</view>
			<view>
				<up-picker title="选择状态" @confirm="onSelectDevEnab" @cancel="showdeviceEnab =!showdeviceEnab" :show="showdeviceEnab" :columns="deviceEnabs"></up-picker>
			</view>

			<view v-if="!1">
				<u-modal @confirm="onSignatureOfSafetyOperator" @cancel="showSignatureOfSafetyOperator = !showSignatureOfSafetyOperator" :showCancelButton="true" :closeOnClickOverlay="true" :show="showSignatureOfSafetyOperator" title="签字板">
					<view class="slot-content">
						<view style="width:750rpx;height:750rpx;">
							<l-signature disableScroll ref="signatureRef" :penColor="penColor" :penSize="penSize" :openSmooth="openSmooth"></l-signature>
						</view>
					</view>
				</u-modal>
			</view>
			<view v-if="!1">
				<u-modal @confirm="onSignatureOfResponsiblePerson" @cancel="showSignatureOfResponsiblePerson = !showSignatureOfResponsiblePerson" :showCancelButton="true" :closeOnClickOverlay="true" :show="showSignatureOfResponsiblePerson" title="签字板">
					<view class="slot-content">
						<view style="width: 750rpx ;height: 750rpx;">
							<l-signature disableScroll ref="signatureRef" :penColor="penColor" :penSize="penSize" :openSmooth="openSmooth"></l-signature>
						</view>
					</view>
				</u-modal>
			</view>
			<view class="canvas_box" v-if="showSignatureOfSafetyOperator">
				<view class="can_content">
					<view style="width: 750rpx ;height: 750rpx;">
						<l-signature disableScroll ref="signatureRef" :penColor="penColor" :penSize="penSize" :openSmooth="openSmooth"></l-signature>
					</view>
					<view class="display_flex" style="width: 100%;justify-content: center;background: #fff;border-radius:13rpx;">
						<view class="btn80" @click="showSignatureOfSafetyOperator = false">取消</view>
						<view style="width: 20rpx;height: 10rpx;"></view>
						<view @click="onSignatureOfSafetyOperator" class="btn80">确认</view>
					</view>
				</view>
			</view>
			<view class="canvas_box" v-if="showSignatureOfResponsiblePerson">
				<view class="can_content">
					<view style="width: 750rpx ;height: 750rpx;">
						<l-signature disableScroll ref="signatureRef" :penColor="penColor" :penSize="penSize" :openSmooth="openSmooth"></l-signature>
					</view>
					<view class="display_flex" style="width: 100%;justify-content: center;background: #fff;border-radius:13rpx;">
						<view class="btn80" @click="showSignatureOfResponsiblePerson = false">取消</view>
						<view style="width: 20rpx;height: 10rpx;"></view>
						<view @click="onSignatureOfResponsiblePerson" class="btn80">确认</view>
					</view>
				</view>
			</view>
		</view>

		<view>
			<up-modal showCancelButton @close="showCronUp =!showCronUp" :show="showCronUp" @confirm="submittedCronUp()" @cancel="showCronUp =!showCronUp" :closeOnClickOverlay="true" title="定时推送配置">
				<view style="width: 100%; ">
					<view style="display: flex; justify-content: space-between;">
						<view v-if="cronOps.enab">
							<up-text type="primary" size="18" text="启用"></up-text>
						</view>
						<view v-if="!cronOps.enab">
							<up-text type="error" size="18" text="禁用"></up-text>
						</view>
						<view>
							<up-switch v-model="cronOps.enab" @change="change"></up-switch>
						</view>
					</view>
					<view style="width: 100%;">
						<br />
						<view>
							<up-text size="18" text="执行周期"></up-text>
						</view>
						<view style="width: 100%;">
							<br />
							<up-subsection @change="onSubsectionCron" :list="['每月','每周','每天']" :current="current"></up-subsection>
						</view>
						<br />
						<view v-if="current == 0" style="width: 100%; display: flex; justify-content: space-between;">
							<view style="width: 30%;">
								<up-button @click="showDay31 =!showDay31" style="width: 100%;" icon="arrow-down" :text=" cronOps.var1 + ' 号'"></up-button>
							</view>

							<view style="60%">
								<up-button @click="showTimes =!showTimes" style="width: 100%;" icon="clock" :text="'时间：'+ cronOps.var2"></up-button>
							</view>
						</view>
						<view v-if="current == 1" style="width: 100%; display: flex; justify-content: space-between;">
							<view style="width: 30%;">
								<up-button @click="showDay7 =!showDay7" style="width: 100%;" icon="arrow-down" :text="'周 ' + cronOps.var1 "></up-button>
							</view>

							<view style="60%">
								<up-button @click="showTimes =!showTimes" style="width: 100%;" icon="clock" :text="'时间：'+ cronOps.var2"></up-button>
							</view>
						</view>
						<view v-if="current == 2" style="width: 100%;">
							<view style="100%">
								<up-button @click="showTimes =!showTimes" style="width: 100%;" icon="clock" :text="'时间：'+ cronOps.var2"></up-button>
							</view>
						</view>
						<br />
						<view>
							<view>
								<up-text size="18" :text="cronOps.described"></up-text>
							</view>
							<!-- <view class="">
								<up-input readonly v-model="cronOps.described"  border="surround"
									@change="change"></up-input>
							</view> -->
						</view>
						<!-- <br />
						<view class="">
							<up-button v-if="current == 0" @click="onCron" type="primary" shape text="生成"></up-button>
							<up-button v-if="current == 1" @click="onCron7" type="primary" shape text="生成"></up-button>
							<up-button v-if="current == 2" @click="onCronTime" type="primary" shape text="生成"></up-button>
						</view> -->
					</view>
				</view>

			</up-modal>
		</view>
		<view>
			<up-modal showCancelButton @close="showCron =!showCron" :show="showCron" @confirm="submittedCron" @cancel="showCron =!showCron" :closeOnClickOverlay="true" title="定时推送配置">
				<view style="width: 100%; ">

					<view style="display: flex; justify-content: space-between;">
						<view v-if="cronOps.enab">
							<up-text type="primary" size="18" text="启用"></up-text>
						</view>
						<view v-if="!cronOps.enab">
							<up-text type="error" size="18" text="禁用"></up-text>
						</view>
						<view>
							<up-switch v-model="cronOps.enab" @change="change"></up-switch>
						</view>
					</view>

					<view style="width: 100%;">
						<br />
						<view>
							<up-text size="18" text="执行周期"></up-text>
						</view>
						<view style="width: 100%;">
							<br />
							<up-subsection @change="onSubsectionCron" :list="['每月','每周','每天']" :current="current"></up-subsection>
						</view>
						<br />
						<view v-if="current == 0" style="width: 100%; display: flex; justify-content: space-between;">
							<view style="width: 30%;">
								<up-button @click="showDay31 =!showDay31" style="width: 100%;" icon="arrow-down" :text=" cronOps.var1 + ' 号'"></up-button>
							</view>

							<view style="60%">
								<up-button @click="showTimes =!showTimes" style="width: 100%;" icon="clock" :text="'时间：'+ cronOps.var2"></up-button>
							</view>
						</view>
						<view v-if="current == 1" style="width: 100%; display: flex; justify-content: space-between;">
							<view style="width: 30%;">
								<up-button @click="showDay7 =!showDay7" style="width: 100%;" icon="arrow-down" :text="'周 ' + cronOps.var1 "></up-button>
							</view>

							<view style="60%">
								<up-button @click="showTimes =!showTimes" style="width: 100%;" icon="clock" :text="'时间：'+ cronOps.var2"></up-button>
							</view>
						</view>
						<view v-if="current == 2" style="width: 100%;">
							<view style="100%">
								<up-button @click="showTimes =!showTimes" style="width: 100%;" icon="clock" :text="'时间：'+ cronOps.var2"></up-button>
							</view>
						</view>
						<br />
						<view>
							<view>
								<up-text size="18" :text="cronOps.described"></up-text>
							</view>
							<!-- <view class="">
								<up-input readonly v-model="cronOps.described"  border="surround"
									@change="change"></up-input>
							</view> -->
						</view>
						<!-- <br />
						<view class="">
							<up-button v-if="current == 0" @click="onCron" type="primary" shape text="生成"></up-button>
							<up-button v-if="current == 1" @click="onCron7" type="primary" shape text="生成"></up-button>
							<up-button v-if="current == 2" @click="onCronTime" type="primary" shape text="生成"></up-button>
						</view> -->
					</view>
				</view>

			</up-modal>
		</view>
		<view>
			<view>
				<up-picker @close="showDay31 =!showDay31" :closeOnClickOverlay="true" @confirm="onCronOps31" title="选择" @cancel="showDay31 =!showDay31" :show="showDay31" :columns="columnsDay31"></up-picker>
			</view>
			<view>
				<up-picker :closeOnClickOverlay="true" @confirm="onCronOps7" title="选择" @close="showDay7 =!showDay7" @cancel="showDay7 =!showDay7" :show="showDay7" :columns="[[1,2,3,4,5,6,7]]"></up-picker>
			</view>
			<view class="">
				<up-datetime-picker title="时间" @confirm="showTimes =!showTimes" @cancel="showTimes =!showTimes" :closeOnClickOverlay="true" ref="datetimePicker" :show="showTimes" v-model="cronOps.var2" mode="time" :formatter="formatter" @close="showTimes =!showTimes"></up-datetime-picker>
			</view>
		</view>
	</view>

</template>

<script>
	import {
		BASE_IP
	} from '@/common/http/url.js'
	import tools from '../../tools/tools.js'
	import moment from "moment"
	import formItem from '../../uni_modules/uview-plus/libs/config/props/formItem.js'
	export default {
		data() {
			return {
				list1: [{
					name: '单位动火证',
				}, {
					name: '动火操作人员',
				}],
				showCronUp: false,
				showDay7: false,
				showTimes: false,
				showDay31: false,
				columnsDay31: [
					[]
				],
				fills: [],
				text: "天",
				classifId: 0,
				showTime: false,
				columns: [
					[1, 7, 14, 30, 360]
				],
				task: "",
				buttons: [{
					text: '确定',
					color: '#409EFF'
				}],
				visible: false,
				showCron: false,
				cron: {
					minutes: "*", //分钟
					hours: "*", //小时
					day: "*", //天
					months: "*", //月
					week: "*", //星期
				},
				current: 0,
				cronOps: {
					id: 0,
					var1: "1",
					var2: "00:00",
					cron: "",
					enab: true,
					described: ""
				},
				filemans: [],
				showUpDayTimes: false,
				showUpDataTimes: false,
				showSignatureOfResponsiblePerson: false,
				showSignatureOfSafetyOperator: false,
				penColor: '#303133',
				penSize: 5,
				signatureUrl: '',
				openSmooth: true,
				base_ip: BASE_IP,
				showDayTimeEnd: false,
				showDayTimeStar: false,
				showDayTimes: false,
				certificateData: "",
				showDataTimeEnd: false,
				showDataTimeStar: false,
				showDataTimes: false,
				certificate: {
					startDataTime: "",
					endDataTime: "",
					dataTimeTemp: "",
					startDayTime: "",
					endDayTime: "",
					dayTimeTemp: ""
					// ,
					// state: [{
					// 		id: 0,
					// 		title: "未认证"
					// 	},
					// 	{
					// 		id: 1,
					// 		title: "认证通过"
					// 	},
					// 	{
					// 		id: 2,
					// 		title: "此证书不合法"
					// 	},
					// 	{
					// 		id: 3,
					// 		title: "此证书无效"
					// 	},
					// 	{
					// 		id: 4,
					// 		title: "证书和本人不符"
					// 	},
					// 	{
					// 		id: 5,
					// 		title: "此证书安全责任人和单位负责人未签名"
					// 	}
					// ]
				},
				showHList: false,
				fileList: [],
				devices: [],
				deviceItem: "",
				showAddFileMan: false,
				showDeviceOps: false,
				hList: [{
						id: 1,
						name: "更新有效日期"
					},
					{
						id: 2,
						name: "更新每天有效时段"
					},
					// {
					// 	id: 3,
					// 	name: "更新状态"
					// },
					// {
					// 	id: 4,
					// 	name: "更新动火证书"
					// },
					{
						id: 8,
						name: "添加动火操作员"
					},
					{
						id: 5,
						name: "获取报警发送接口",
						subname: "POST 请求",
					},
					{
						id: 9,
						name: "获取人脸发送接口",
						subname: "POST 请求 参数:（mqt） mqtt连接主题",
					},
					{
						id: 10,
						name: "设置人脸过期时间"
					},
					{
						id: 6,
						name: "查看历史记录"
					},
					{
						id: 7,
						name: "重新上传动火证书",
						color: "#fa3534"
					}
				],
				deviceList: [{
						id: 0,
						name: '启用'
					}, {
						id: 1,
						name: "开始作业"
					}, {
						id: 2,
						name: "人脸识别间隔"
					},
					{
						id: 6,
						name: "获取开始作业接口"
					},
					{
						id: 7,
						name: "获取停止作业接口"
					}, {
						id: 8,
						name: "获取人脸识别接口",
						subname: "注意该接口默认使用设备编号转为MQTT主题",
					}, {
						id: 3,
						name: "禁用",
						color: "#fa3534"
					},
					{
						id: 4,
						name: "停止作业",
						color: "#fa3534"
					},
					{
						id: 5,
						name: "删除此设备",
						color: "#fa3534"
					}
				],
				showdeviceTime: false,
				deviceTimes: [
					[
						10, 20, 30, 60, 90, 120, 150, 180
					]
				],
				showdeviceEnab: false,
				deviceEnabs: [
					['禁用', '启用']
				],
				showdeviceTypes: false,
				showAddDevice: false,
				deviceTypes: [
					[
						"报警", "避雷", "电器", "定位器", "摄像头", "水压表", "天然气", "消防", "烟感", "智慧屏"
					]
				],
				addDevice: {
					number: "",
					type: "",
					enable: {
						value: 1,
						label: "启用"
					},
					faceSpan: "" //人脸识别到期时间
				},
				showSelectTimeSet: false,
				minTime: "",
				minTime1: "",
				tabsIndex: 0
			}
		},
		onPullDownRefresh() {
			this.queryDevices()
			this.queryWord()
			setTimeout(() => {
				//结束下拉刷新
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onShow() {
			this.queryWord()
			this.queryDevices()
		},
		onLoad() {
			this.queryDevices()
			this.queryWord()
			this.onColumnsDay31()
			let minTime = tools.getTodayTimestamp()
			console.log(minTime)
			// console.log(tools.parseTimestampToDate(minTime))
			this.minTime1 = minTime
			this.minTime = minTime
		},
		methods: {
			preventScroll(e) {
				// 阻止事件冒泡和默认行为
				e.stopPropagation();
				e.preventDefault();
			},
			tabClick(item) {
				console.log('item', item);
				this.tabsIndex = item.index
			},
			onColumnsDay31() {
				let number = 31
				for (let i = 1; i <= number; i++) {
					// console.log(i)
					this.columnsDay31[0].push(i)
				}
			},
			submittedCronUp() {
				let cid = this.current
				if (cid == 0) {
					this.onCron()
				}
				if (cid == 1) {
					this.onCron7()
				}
				if (cid == 2) {
					this.onCronTime()
				}
				console.log(this.cronOps)
				let url = BASE_IP + "pc/task/unit/up"
				let user = uni.getStorageSync("user")
				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: {
						'json': JSON.stringify(this.cronOps)
					},
					method: "POST",
					url: url,
					success: (res) => {
						// console.log(res)
						if (res.statusCode == 200) {
							if (res.data.code == 1) {
								uni.showToast({
									title: "更新成功！",
									icon: "success"
								})
								this.queryWord()

								this.showCronUp = !this.showCronUp
								return
							} else {
								uni.showToast({
									title: "更新失败！",
									icon: "error"
								})
							}
						} else {
							uni.showToast({
								title: "更新失败！",
								icon: "error"
							})
						}
					}
				})
			},
			submittedCron() {
				let cid = this.current
				if (cid == 0) {
					this.onCron()
				}
				if (cid == 1) {
					this.onCron7()
				}
				if (cid == 2) {
					this.onCronTime()
				}
				console.log(this.cronOps)

				let url = BASE_IP + "pc/task/unit"
				let user = uni.getStorageSync("user")
				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: {
						'json': JSON.stringify(this.cronOps)
					},
					method: "POST",
					url: url,
					success: (res) => {
						// console.log(res)
						if (res.statusCode == 200) {
							if (res.data.code == 1) {
								uni.showToast({
									title: "添加成功！",
									icon: "success"
								})
								this.queryWord()

								this.showCron = !this.showCron
								return
							} else {
								uni.showToast({
									title: "添加失败！",
									icon: "error"
								})
							}
						} else {
							uni.showToast({
								title: "添加失败！",
								icon: "error"
							})
						}
					}
				})
				// uni.showModal({
				// 	title: "提示",
				// 	content: "您确定要修改此配置吗？",
				// 	success: (res) => {
				// 		if (res.confirm) {
				// 			this.showCron = !this.showCron
				// 			let enab = 1
				// 			if (!this.cronOps.enab) {
				// 				enab = 0
				// 			}
				// 			this.isValid(this.cronOps.id, this.cronOps.cron, enab)
				// 		}
				// 	}
				// })

			},
			onShowCron(res) {
				console.log(res)
				let cron = res.cron
				let enabled = false
				if (res.isEnabled == 1) {
					enabled = true
				}
				this.cronOps.id = res.id
				this.cronOps.cron = cron
				this.cronOps.enab = enabled
				this.cronOps.described = res.described
				this.showCron = !this.showCron
			},
			onCronOps7(res) {
				this.cronOps.var1 = res.value[0]
				this.showDay7 = !this.showDay7
			},
			onCronTime() {
				let time = this.formatTime(this.cronOps.var2)
				let cron = "0 " + time.var2 + " " + time.var1 + " *" + " * " + "?"
				this.cronOps.cron = cron
				let described = "每天的 " + this.cronOps.var2 + " 执行一次"
				this.cronOps.described = described
			},
			onCron7() {
				let time = this.formatTime(this.cronOps.var2)
				let cron = "0 " + time.var2 + " " + time.var1 + " ?" + " * " + this.cronOps.var1
				let described = "每周的 周" + this.cronOps.var1 + " " + this.cronOps.var2 + " 执行一次"
				this.cronOps.cron = cron
				console.log(described)
				this.cronOps.described = described
			},
			onCron() {
				let time = this.formatTime(this.cronOps.var2)
				let cron = "0 " + time.var2 + " " + time.var1 + " " + this.cronOps.var1 + " * " + "?"
				this.cronOps.cron = cron
				let described = "每月的 " + this.cronOps.var1 + " 号" + " " + this.cronOps.var2 + " 执行一次"
				this.cronOps.described = described
				console.log(described)
			},
			formatTime(time) {
				let hours = time[0] === '0' ? time[1] : time.substring(0, 2);
				let minutes = time[3] === '0' ? time[4] : time.substring(3, 5);
				let newTime = `${hours}:${minutes}`;

				let timeObj = {
					var1: hours,
					var2: minutes
				}
				console.log(timeObj); // 输出: 9:9

				return timeObj
			},
			onCronOps31(res) {
				// console.log(res)
				this.cronOps.var1 = res.value[0]
				this.showDay31 = !this.showDay31
			},
			onSubsectionCron(res) {
				console.log(res)
				this.cronOps.var1 = 1
				this.current = res
			},
			enableOn(item, res) {
				uni.showModal({
					title: "提示",
					content: "您确定要启用此操作员吗？",
					success: (r) => {
						if (r.confirm) {
							this.enableFileMan(item, res)
						}
					}
				})
			},
			enableOff(item, res) {
				uni.showModal({
					title: "提示",
					content: "您确定要禁用此操作员吗？",
					success: (r) => {
						if (r.confirm) {
							this.enableFileMan(item, res)
						}
					}
				})
			},
			enableFileMan(item, res) {
				let url = BASE_IP + "pc/hot/work/enable/fileman/" + item.id + "/" + res
				console.log(url)
				let user = uni.getStorageSync("user")
				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					url: url,
					method: "POST",
					success: (r) => {
						if (r.statusCode == 200) {
							if (r.data.code == 1) {
								uni.showToast({
									title: "更新成功！",
									icon: "success"
								})
								this.queryDevices()
								return
							} else {
								uni.showToast({
									title: "更新失败！",
									icon: "success"
								})
							}
						}
						uni.showToast({
							title: "更新失败！",
							icon: "success"
						})
					}

				})
			},
			delFileMan(res) {
				uni.showModal({
					title: "提示",
					content: "您确定要删除此操作员吗？",
					success: (r1) => {
						if (r1.confirm) {
							console.log(res)
							let url = BASE_IP + "pc/hot/work/del/fileman/" + res.id
							let user = uni.getStorageSync("user")
							uni.request({
								header: {
									"Authorization": user.token,
									'Content-Type': 'application/x-www-form-urlencoded'
								},
								url: url,
								method: "DELETE",
								success: (r) => {
									if (r.statusCode == 200) {
										if (r.data.code == 1) {
											uni.showToast({
												title: "删除成功！",
												icon: "success"
											})
											this.queryDevices()
											return
										} else {
											uni.showToast({
												title: "删除失败！",
												icon: "success"
											})
										}
									}
									uni.showToast({
										title: "删除失败！",
										icon: "success"
									})
								}

							})
						}
					}
				})
			},
			onSelectDevEnab(res) {
				console.log(res)
				this.addDevice.enable.label = res.value[0]
				this.addDevice.enable.value = res.indexs[0]
				this.showdeviceEnab = !this.showdeviceEnab
			},
			onSelectDevType(res) {
				console.log(res)
				this.addDevice.type = res.value[0]
				this.showdeviceTypes = !this.showdeviceTypes
			},
			onSelectDevTimes1(res) {
				console.log(res)
				this.showdeviceTime1 = !this.showdeviceTime1
				let url = BASE_IP + "pc/device/up/2/" + res.value[0] + "/" + this.deviceItem.id
				let user = uni.getStorageSync("user")
				console.log(url)
				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					url: url,
					method: "POST",
					success: (res) => {
						console.log(res)
						if (res.statusCode == 200) {
							if (res.data.code == 1) {
								uni.showToast({
									title: res.data.data,
									icon: "success"
								})
								this.queryDevices()
							} else {
								uni.showToast({
									title: "操作失败",
									icon: "error"
								})
							}
						} else {
							uni.showToast({
								title: "操作失败",
								icon: "error"
							})
						}
					},
					fail: (res) => {
						uni.showToast({
							title: "操作失败",
							icon: "error"
						})
					}
				})

			},
			onSelectDevTimes(res) {
				console.log(res)
				this.addDevice.faceSpan = res.value[0]
				this.showdeviceTime = !this.showdeviceTime
			},
			onUpSelctDayTime() {
				// console.log(this.ce)
				if (!this.certificate.startDayTime) {
					uni.showToast({
						title: "选择开始时段！",
						icon: "error"
					})
					return
				}

				if (!this.certificate.endDayTime) {
					uni.showToast({
						title: "选择结束时段！",
						icon: "error"
					})
					return
				}

				let url = BASE_IP + "pc/hot/work/up/daytime/" + this.certificate.startDayTime + "/" + this.certificate
					.endDayTime + "/" + this.certificateData.id
				let user = uni.getStorageSync("user")
				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					url: url,
					method: "POST",
					success: (res) => {
						console.log(res)
						if (res.statusCode == 200) {
							if (res.data.code == 1) {
								uni.showToast({
									title: res.data.data,
									icon: "success"
								})
								this.certificate.startDataTime = ""
								this.certificate.startDayTime = ""
								this.certificate.endDataTime = ""
								this.certificate.endDayTime = ""
								this.certificate.dataTimeTemp = ""
								this.certificate.dayTimeTemp = ""

								this.queryWord()
							} else {
								uni.showToast({
									title: res.data.msg,
									icon: "error"
								})
							}
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: "error"
							})
						}
					}
				})
				this.showUpDayTimes = !this.showUpDayTimes
			},
			onUpSelctDataTime() {
				if (!this.certificate.startDataTime) {
					uni.showToast({
						title: "选择开始日期！",
						icon: "error"
					})
					return
				}

				if (!this.certificate.endDataTime) {
					uni.showToast({
						title: "选择结束日期！",
						icon: "error"
					})
					return
				}

				let url = BASE_IP + "pc/hot/work/up/date/" + this.certificate.startDataTime + "/" + this.certificate
					.endDataTime + "/" + this.certificateData.id
				let user = uni.getStorageSync("user")
				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					url: url,
					method: "POST",
					success: (res) => {
						console.log(res)
						if (res.statusCode == 200) {
							if (res.data.code == 1) {
								uni.showToast({
									title: res.data.data,
									icon: "success"
								})
								this.certificate.startDataTime = ""
								this.certificate.startDayTime = ""
								this.certificate.endDataTime = ""
								this.certificate.endDayTime = ""
								this.certificate.dataTimeTemp = ""
								this.certificate.dayTimeTemp = ""

								this.queryWord()
							} else {
								uni.showToast({
									title: res.data.msg,
									icon: "error"
								})
							}
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: "error"
							})
						}
					}
				})
				this.showUpDataTimes = !this.showUpDataTimes
			},
			onSignatureOfResponsiblePerson() {
				console.log("确认画")
				this.$refs.signatureRef.canvasToTempFilePath({
					success: (res) => {
						// 是否为空画板 无签名
						console.log('空画', res.isEmpty)
						if (res.isEmpty) {
							return
						}
						let user = uni.getStorageSync("user")
						console.log("签字图片：", res.tempFilePath)
						let hid = this.certificateData.id
						let url = BASE_IP + "pc/hot/work/unit/responsible/sign/" + hid
						this.upload(url, res.tempFilePath, "")
						console.log(hid)
						this.showSignatureOfResponsiblePerson = !this.showSignatureOfResponsiblePerson
					}
				})
			},
			onSignatureOfSafetyOperator() {
				console.log("确认话")
				this.$refs.signatureRef.canvasToTempFilePath({
					success: (res) => {
						// 是否为空画板 无签名
						console.log('空话', res.isEmpty)
						if (res.isEmpty) {
							return
						}
						let user = uni.getStorageSync("user")
						console.log("签字图片：", res.tempFilePath)
						let hid = this.certificateData.id
						let url = BASE_IP + "pc/hot/work/secure/sign/" + hid
						this.upload(url, res.tempFilePath, "")
						console.log(hid)
						this.showSignatureOfSafetyOperator = !this.showSignatureOfSafetyOperator
					}
				})
			},
			test(res) {
				console.log(res)
				this.onPreview(res)
			},
			onPreview(url) {
				console.log(url)
				const regex = /\.(pdf)$/i;
				const regexv = /\.(jpg|png|jpeg)$/i;
				const matchPdf = regex.test(url);
				const matchPdfv = regexv.test(url);
				if (matchPdf) {

					let urls = BASE_IP + url
					// console.log(urls)
					let filelist = {
						name: '预览',
						fileSrc: urls,
						isFileDown: true
					}
					uni.navigateTo({
						url: "/pages/common/fileView",
						success: (res) => {
							// 通过eventChannel向被打开页面传送数据
							res.eventChannel.emit("dataFun", {
								data: filelist,
							});
						},
					});
				} else if (matchPdfv) {
					uni.showLoading({
						title: "正在加载"
					})
					let urls = BASE_IP + url
					console.log(urls)
					let arr = []
					arr.push(urls)
					uni.previewImage({
						urls: arr,
						current: arr.length,
						success(r) {
							uni.hideLoading();
							console.log(r)
						},
						fail() {
							uni.hideLoading();
							uni.showToast({
								title: "加载失败",
								icon: "error"
							})
						}
					})
				}
			},
			queryWord() {
				let user = uni.getStorageSync("user")
				let url = BASE_IP + "pc/hot/work/get/work"
				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "GET",
					url: url,
					success: (res) => {
						if (res.statusCode == 200) {
							// console.log(res)
							if (res.data.code == 1) {
								this.certificateData = res.data.data
								console.log(this.certificateData)

								// if (this.certificateData.filMan) {
								// 	let filemanstrlist = JSON.parse(this.certificateData.filMan)
								// 	this.filemans = []
								// 	for (let i = 0; i < filemanstrlist.length; i++) {
								// 		let filemans = JSON.parse(filemanstrlist[i])
								// 		console.log(filemans)
								// 		this.filemans.push(filemans)
								// 	}
								// }

							} else {
								this.certificateData = ""
							}
						}
					}
				})
			},
			onSelctDayTime() {
				if (!this.certificate.startDayTime) {
					uni.showToast({
						title: "选择开始时段",
						icon: "error"
					})
					return
				}
				if (!this.certificate.endDayTime) {
					uni.showToast({
						title: "选择结束时段",
						icon: "error"
					})
					return
				}
				this.certificate.dayTimeTemp = this.certificate.startDayTime + " 至 " + this.certificate.endDayTime
				this.showDayTimes = !this.showDayTimes
			},
			onDayTimeEnd(res) {
				console.log(res)
				this.certificate.endDayTime = res.value
				this.showDayTimeEnd = !this.showDayTimeEnd
			},
			onDayTimeStar(res) {
				console.log(res)
				this.certificate.startDayTime = res.value
				this.showDayTimeStar = !this.showDayTimeStar
			},
			onSelctDataTime() {
				if (!this.certificate.startDataTime) {
					uni.showToast({
						title: "选择开始日期！",
						icon: "error"
					})
					return
				}
				if (!this.certificate.endDataTime) {
					uni.showToast({
						title: "选择结束日期！",
						icon: "error"
					})
					return
				}
				this.certificate.dataTimeTemp = this.certificate.startDataTime + " 至 " + this.certificate.endDataTime
				this.showDataTimes = !this.showDataTimes
			},
			onDataTimeEnd(res) {
				// console.log(res)
				let datatime = tools.parseTimestampToDate(res)
				console.log(datatime)
				this.certificate.endDataTime = datatime
				this.showDataTimeEnd = !this.showDataTimeEnd
			},
			onDataTimeStar(res) {
				// console.log(res)
				let datatime = tools.parseTimestampToDate(res)
				console.log(datatime)
				this.minTime1 = res.value
				this.certificate.startDataTime = datatime
				this.showDataTimeStar = !this.showDataTimeStar
			},
			formatter(type, value) {
				if (type === 'year') {
					return `${value}年`
				}
				if (type === 'month') {
					return `${value}月`
				}
				if (type === 'day') {
					return `${value}日`
				}
				return value
			},
			uploadCertificate() { //上传动火证书
				let user = uni.getStorageSync("user")
				// if (user.power != 1) {
				// 	uni.showModal({
				// 		title: "提示",
				// 		showCancel: false,
				// 		content: "请使用管理员账号进行上传操作"
				// 	})
				// 	return
				// }



				if (!this.certificate.startDataTime) {
					uni.showModal({
						title: "提示",
						showCancel: false,
						content: "请选择有效日期开始时间"
					})
					return
				}
				if (!this.certificate.endDataTime) {
					uni.showModal({
						title: "提示",
						showCancel: false,
						content: "请选择有效日期结束时间"
					})
					return
				}
				if (!this.certificate.startDayTime) {
					uni.showModal({
						title: "提示",
						showCancel: false,
						content: "请选择每天开始有效时段"
					})
					return
				}
				if (!this.certificate.endDayTime) {
					uni.showModal({
						title: "提示",
						showCancel: false,
						content: "请选择每天结束有效时段"
					})
					return
				}
				let _this = this
				uni.showModal({
					title: "提示",
					showCancel: false,
					content: "请使用横屏拍照或者横屏图片",
					success: (r) => {
						if (r.confirm) {
							let url = BASE_IP + "pc/hot/work/certificate"
							uni.chooseImage({
								count: 1,
								sizeType: ['original', 'compressed'],
								sourceType: ['camera', 'album'],
								success: (res) => {
									const tempFilePaths = res.tempFilePaths[0];
									_this.upload(url, tempFilePaths, JSON.stringify(this
										.certificate))
								}
							});
						}
					}
				})
			},
			/**
			 * @param {Object} url 上传文件的服务器地址
			 * @param {Object} filePath 本地文件的路径
			 * @param {object} data 传输入的数据
			 */
			upload(url, filePath, data) {
				console.log(data)
				console.log("====>", url, filePath)
				let user = uni.getStorageSync("user")
				uni.uploadFile({
					header: {
						"Authorization": user.token,
					},
					formData: {
						dataJson: data
					},
					name: "file",
					url: url,
					filePath: filePath,
					success: (res) => {
						console.log(res)
						if (res.statusCode == 500) {
							uni.showToast({
								icon: "error",
								title: "上传失败"
							})
							return
						}
						if (res.statusCode == 404) {
							console.log(res)
							uni.showToast({
								icon: "error",
								title: "上传失败"
							})
							return
						}
						if (res.statusCode == 200) {
							let data = JSON.parse(res.data)
							console.log(data)
							if (data.code != 0) {
								this.queryWord()

								this.certificate.startDataTime = ""
								this.certificate.startDayTime = ""
								this.certificate.endDataTime = ""
								this.certificate.endDayTime = ""
								this.certificate.dataTimeTemp = ""
								this.certificate.dayTimeTemp = ""

								uni.showModal({
									title: "提示",
									content: data.data,
									showCancel: false
								})

								return
							} else {

								uni.showModal({
									title: "提示",
									content: data.msg,
									showCancel: false
								})
								return
							}

							// uni.showToast({
							// 	title: "上传成功",
							// 	icon: "success"
							// })
							// this.getPrall()
						}
					},
					fail: (res) => {
						uni.showToast({
							title: "上传失败",
							icon: "error"
						})
					}
				})
			},
			onHlist(res) {
				let user = uni.getStorageSync("user")
				// if (user.power != 1) {
				// 	uni.showToast({
				// 		title: "权限不足",
				// 		icon: "error"
				// 	})
				// 	return
				// }
				console.log(res)
				if (res.id == 1) {
					this.showUpDataTimes = !this.showUpDataTimes
				}
				if (res.id == 2) {
					this.showUpDayTimes = !this.showUpDayTimes
				}
				if (res.id == 7) {
					this.certificateData = ""
				}
				if (res.id == 6) {
					uni.navigateTo({
						url: "/pagesWork/hotWork/hotWorkHistory"
					})
				}
				if (res.id == 5) {
					console.log(user)
					let url = BASE_IP + "pc/hot/work/call/police/unit/" + user.unitId
					console.log(url)
					uni.setClipboardData({
						data: url,
						success: (res) => {
							uni.showToast({
								title: "复制成功!",
								icon: "success"
							})
						}
					})

				}
				if (res.id == 9) {
					console.log(user)
					let url = BASE_IP + "pc/hot/work/face/auth/" + user.unitId + "/{{mqt}}"
					console.log(url)
					uni.setClipboardData({
						data: url,
						success: (res) => {
							uni.showToast({
								title: "复制成功!",
								icon: "success"
							})
						}
					})
				}
				if (res.id == 10) {
					this.showCronUp = !this.showCronUp
				}
				if (res.id == 8) {
					this.showAddFileMan = !this.showAddFileMan
				}
			},
			onAddFileMan() {
				if (this.fileManAccount == "") {
					uni.showToast({
						title: "请输入账号",
						icon: "error"
					})
					return
				}
				let url = BASE_IP + "pc/hot/work/add/fileman/" + this.fileManAccount + "/" + this.certificateData.id
				console.log(url)
				let user = uni.getStorageSync("user")
				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					url: url,
					method: "POST",
					success: (res) => {
						console.log(res)
						if (res.statusCode == 200) {
							if (res.data.code != 1) {
								uni.showModal({
									title: "提示",
									content: res.data.msg,
									showCancel: false
								})
								return
							} else {
								uni.showModal({
									title: "提示",
									content: res.data.data,
									showCancel: false
								})
								this.queryDevices()
							}
						} else {
							uni.showToast({
								title: "添加失败",
								icon: "error"
							})
						}
					},
					fail: (res) => {
						uni.showToast({
							title: "添加失败",
							icon: "error"
						})
					}
				})
				this.fileManAccount = ""
				this.showAddFileMan = !this.showAddFileMan
			},
			onAddDevice() {
				console.log(this.addDevice)
				if (this.addDevice.number == "") {
					uni.showToast({
						title: "设备号为空",
						icon: "error"
					})
					return
				}
				if (this.addDevice.type == "") {
					uni.showToast({
						title: "类型为空",
						icon: "error"

					})
					return
				}

				if (this.addDevice.faceSpan == "") {
					uni.showToast({
						title: "时间为空",
						icon: "error"

					})
					return
				}
				let url = BASE_IP + "pc/device/save/" + this.addDevice.number + "/" + this.addDevice.type + "/" + this
					.addDevice.enable.value + "/" + this.addDevice.faceSpan
				let user = uni.getStorageSync("user")
				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					url: url,
					method: "POST",
					success: (res) => {
						console.log(res)
						if (res.statusCode == 200) {
							if (res.data.code == 1) {
								uni.showToast({
									icon: "success",
									title: res.data.data
								})
								this.addDevice.enable.label = "启用"
								this.addDevice.enable.value = 1
								this.addDevice.faceSpan = ""
								this.addDevice.number = ""
								this.addDevice.type = ""
								this.queryDevices()
							} else {
								uni.showToast({
									icon: "error",
									title: res.data.msg
								})
							}
						} else {
							uni.showToast({
								icon: "error",
								title: "添加失败"
							})
						}
					},
					fail: (res) => {
						uni.showToast({
							icon: "error",
							title: "添加失败"
						})
					}
				})

				this.showAddDevice = !this.showAddDevice

			},
			onDeviceOps(res) {
				let user = uni.getStorageSync("user")
				console.log(res)
				let url;
				if (res.id == 0) {
					url = BASE_IP + "pc/device/up/" + res.id + "/0/" + this.deviceItem.id
				}
				if (res.id == 1) {
					// url = BASE_IP + "pc/device/up/" + res.id + "/1/" + this.deviceItem.id
					url = BASE_IP + "pc/device/jobs/start/" + this.deviceItem.id
				}
				if (res.id == 2) {
					// url = BASE_IP + "pc/device/up/"+res.id+"/2/" + this.deviceItem.id
					this.showdeviceTime1 = !this.showdeviceTime1
				}
				if (res.id == 3) {
					url = BASE_IP + "pc/device/up/" + res.id + "/3/" + this.deviceItem.id
				}
				if (res.id == 4) {
					url = BASE_IP + "pc/device/jobs/stop/" + this.deviceItem.id
				}
				if (res.id == 6) {
					url = BASE_IP + "pc/device/jobs/start/" + this.deviceItem.id
					uni.setClipboardData({
						data: url,
						success: (r) => {
							uni.showToast({
								title: "复制成功!",
								icon: "success"
							})
						}
					})
					return
				}
				if (res.id == 7) {
					url = BASE_IP + "pc/device/jobs/stop/" + this.deviceItem.id
					uni.setClipboardData({
						data: url,
						success: (r) => {
							uni.showToast({
								title: "复制成功!",
								icon: "success"
							})
						}
					})
					return
				}
				if (res.id == 8) {
					// console.log()
					let mqtt = this.deviceItem.deviceNumber
					url = BASE_IP + "pc/device/face/mqt/" + user.unitId + "/" + mqtt
					console.log(url)
					uni.setClipboardData({
						data: url,
						success: (r) => {
							uni.showToast({
								title: "复制成功!",
								icon: "success"
							})
						}
					})
					return
				}
				// if(res.id == 9){
				// 	this.showAddFileMan =!this.showAddFileMan
				// }
				if (res.id == 5) {
					uni.showModal({
						title: "提示",
						content: "您确定删除此设备吗？",
						success: (res) => {
							if (res.confirm) {
								let url = BASE_IP + "pc/device/up/5/5/" + this.deviceItem.id
								uni.request({
									header: {
										"Authorization": user.token,
										'Content-Type': 'application/x-www-form-urlencoded'
									},
									url: url,
									method: "POST",
									success: (res) => {
										console.log(res)
										if (res.statusCode == 200) {
											if (res.data.code == 1) {
												uni.showToast({
													title: "删除成功",
													icon: "success"
												})
												this.queryDevices()
											} else {
												uni.showToast({
													title: "操作失败",
													icon: "error"
												})
											}
										} else {
											uni.showToast({
												title: "操作失败",
												icon: "error"
											})
										}
									},
									fail: (res) => {
										uni.showToast({
											title: "操作失败",
											icon: "error"
										})
									}
								})

							} else {
								return
							}
						}
					})
				}
				// console.log(url)

				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					url: url,
					method: "POST",
					success: (res) => {
						console.log(res)
						if (res.statusCode == 200) {
							if (res.data.code == 1) {
								uni.showToast({
									title: res.data.data,
									icon: "success"
								})
								this.queryDevices()
							} else {
								uni.showToast({
									title: "操作失败",
									icon: "error"
								})
							}
						} else {
							uni.showToast({
								title: "操作失败",
								icon: "error"
							})
						}
					},
					fail: (res) => {
						uni.showToast({
							title: "操作失败",
							icon: "error"
						})
					}
				})

			},
			onDeviceOpsShow(res) {
				console.log(res)
				this.deviceItem = res
				this.showDeviceOps = !this.showDeviceOps
			},
			toFileMan(res) {
				console.log(res)
				uni.navigateTo({
					url: "/pagesMine/admin/fileMan/fileMan?id=" + res.id
				})
			},
			onShowFileMan(res) {
				this.deviceItem = res
				this.showAddFileMan = !this.showAddFileMan
			},
			queryDevices() {
				let url = BASE_IP + "pc/hot/work/get/fileman"
				let user = uni.getStorageSync("user")
				uni.request({
					header: {
						"Authorization": user.token,
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					url: url,
					success: (res) => {
						console.log(res)
						if (res.statusCode == 200) {
							if (res.data.code == 0) {
								this.devices = []
								return
							}
							if (res.data.code == 1) {
								this.filemans = []
								this.filemans = res.data.data
								console.log(this.filemans)
								// this.devices = []
								// let data_json = JSON.parse(res.data.data)
								// for (let index in data_json) {
								// 	this.devices.push(JSON.parse(data_json[index]))
								// }
							}
						}
					}
				})
			}
		}
	}
</script>

<style scoped>
	/* .page {
		background-color: #F2F3F5;
	} */

	.u-page__item {
		width: 98%;
	}

	.fui-item__box {
		width: 100%;
		padding: 26rpx 32rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}

	.charts-user-list-son {
		width: 95%;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		margin: 0 auto;
	}

	.h-content {
		margin: 10rpx auto;
		width: 90%;
		/* padding-bottom: 2rpx;
		padding-top: 2rpx; */
		background-color: #ffffff;
		border: 1px solid #e4e7ed;
		border-radius: 18rpx;
	}

	.canvas_box {
		position: fixed;
		left: 0;
		top: 0;
		z-index: 999;
		background: rgba(000, 000, 000, .5);
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		.can_content {
			background: #fff;
			width: 80%;
			height: 60%;
			border-radius: 13rpx;
		}
	}

	.btn80 {
		background-color: #49A0FF;
		color: #fff;
		padding: 14rpx 100rpx;
		border-radius: 8rpx;
		margin-bottom: 10rpx;
	}

	.no-scroll {
		overflow: hidden;
	}
</style>